﻿namespace _5._8._02.Exceptions.Exceptions
{
    using System;

    public class ExamResult
    {
        public int Grade { get; private set; }
        public int MinGrade { get; private set; }
        public int MaxGrade { get; private set; }
        public string Comments { get; private set; }

        public ExamResult(int grade, int minGrade, int maxGrade, string comments)
        {
            if (grade < 0)
            {
                throw new ArgumentOutOfRangeException("grade", "Grade should not be less than zero");
            }

            if (minGrade < 0)
            {
                throw new ArgumentOutOfRangeException("minGrade", "MinGrade should not be less than zero");
            }

            if (maxGrade <= minGrade)
            {
                throw new ArgumentOutOfRangeException("MaxGrade should be higher than minGrade");
            }

            if (string.IsNullOrWhiteSpace(Comments))
            {
                throw new ArgumentException("Comments should not be null or empty");
            }

            if (grade < minGrade || grade > maxGrade)
            {
                throw new ArgumentOutOfRangeException(
                    "grade",
                    string.Format("grade should be in the range from {0} to {1}.", minGrade, maxGrade));
            }

            this.Grade = grade;
            this.MinGrade = minGrade;
            this.MaxGrade = maxGrade;
            this.Comments = comments;
        }
    }
}